﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.CodeRush.StructuralParser;
using CR.StyleCop.Utils;

namespace CR.StyleCop.Extensions {
    internal static class ElementsExtensions {
        public static IEnumerable<OutputT> SelectWhereElement<OutputT>(this IEnumerable<IElement> self) where OutputT : IElement {
            return self.Where(e => e is OutputT).Cast<OutputT>();
        }
        public static IEnumerable<OutputT> SelectLanguageElement<OutputT>(this IEnumerable<IElement> self) where OutputT : LanguageElement {
            return self.Select(e => SourceUtils.ConvertToLanguageElement(e))
                .Select(le => le as OutputT).Where(ce => ce != null);
        }
    }
}
